package com.cloud.lan.api.manage;

import com.cloud.lan.api.dto.req.BaseReq;
import com.cloud.lan.api.dto.req.DelReq;
import com.cloud.lan.api.dto.req.LanGoodsEvaluateReq;
import com.cloud.lan.entity.base.BaseResponse;
import com.cloud.lan.service.ILanGoodsEvaluateService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 商品评价管理入口
 * @author ErKang
 * @date Created in 2022-05-21 04:24
 * @title TestApi.java
 * Department: Product development
 */
@RestController
@RequestMapping(value = {"/v1/manage/goods/evaluate/"}, method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json"})
public class LanGoodsEvaluateManageApi {

    @Resource
    ILanGoodsEvaluateService lanGoodsEvaluateService;

    @RequestMapping("manageList")
    public BaseResponse<Object> manageList(LanGoodsEvaluateReq req) {
        return lanGoodsEvaluateService.manageList(req);
    }

    @RequestMapping("add")
    public BaseResponse<Object> add(@RequestHeader(BaseReq.ut) String token, @RequestBody LanGoodsEvaluateReq req) {
        req.setToken(token);
        return lanGoodsEvaluateService.add(req);
    }

    @RequestMapping("update")
    public BaseResponse<Object> update(@RequestHeader(BaseReq.ut) String token, @RequestBody LanGoodsEvaluateReq req) {
        req.setToken(token);
        return lanGoodsEvaluateService.update(req);
    }

    @GetMapping("delete")
    public BaseResponse<Object> delete(@RequestHeader(BaseReq.ut) String token, DelReq req) {
        req.setToken(token);
        return lanGoodsEvaluateService.delete(req);
    }

    @RequestMapping("importEvaluate")
    public BaseResponse<Object> importEvaluate(@RequestHeader(BaseReq.ut) String token, @RequestParam("file") MultipartFile file) {
        return lanGoodsEvaluateService.importEvaluate(token, file);
    }

    @RequestMapping("topping")
    public BaseResponse<Object> topping(@RequestHeader(BaseReq.ut) String token, @RequestBody LanGoodsEvaluateReq req) {
        req.setToken(token);
        return lanGoodsEvaluateService.topping(req);
    }
}
